package com.zyh.number;

import java.math.BigDecimal;

public class NumberDemo6 {
    public static void main(String[] args) {
        String num1="0.1";
        String num2="0.2";
        BigDecimal bigDecimal1 = new BigDecimal(num1);
        BigDecimal bigDecimal2 = new BigDecimal(num2);
        BigDecimal add = bigDecimal1.add(bigDecimal2);
        System.out.println("add = " + add);
        BigDecimal subtract = bigDecimal1.subtract(bigDecimal2);
        System.out.println("subtract = " + subtract);
        BigDecimal multiply = bigDecimal1.multiply(bigDecimal2);
        System.out.println("multiply = " + multiply);
        BigDecimal divide = bigDecimal1.divide(bigDecimal2);
        System.out.println("divide = " + divide);
        BigDecimal[] bigDecimals = bigDecimal1.divideAndRemainder(bigDecimal2);
        System.out.println(bigDecimals[0]);
        System.out.println(bigDecimals[1]);
        System.out.println(bigDecimals.length);
    }
}
